import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:lishopflu/base/base_import.dart';
import 'package:lishopflu/base/controller_import.dart';
import 'base_list_controller.dart';
import 'base_page.dart';

abstract class BaseListPage<T extends BaseListController> extends BasePage<T> {


  Widget listBody(BuildContext context, Widget child){
    return EasyRefresh(
      child: ListUtil.isEmpty(controller.mList) ? emptyView() : (
          child != null?child:ListView.builder(
            itemCount: ListUtil.isEmpty(controller.mList) ? 0 : controller.mList.length,
            itemBuilder: (BuildContext context, int index){
              return ListTile(
                title: Text('index '+index.toString()),
                onTap: (){
                  toast('click '+index.toString());
                },
              );
              },
          )
      ),
      onRefresh: () async{
        controller.page = 0;
        controller.isFresh = true;
        controller.loadData();
      },
      onLoad: () async {
        controller.loadData();
      },
    );
  }
}